<template lang="html">
  <div class="">
    <mt-field label="用户名" placeholder="请输入用户名" v-model="formItem.name"></mt-field>
    <mt-field label="密码" placeholder="请输入密码" type="password" v-model="formItem.password"></mt-field>
    <mt-button type="primary" @click.native="register">注册</mt-button>
    <mt-button type="default" @click.native="login">登录</mt-button>
  </div>
</template>

<script>
// import axios from '../utils/request'

export default {
  data () {
    return {
      formItem:{
        name:'',
        password:''
      },
      msg: 'Login'
    }
  },
  methods:{
    login(){
      // this.$router.push({
      //   path:'/'
      // })
      // console.log(this.$axios);
        this.$axios.post('login',this.formItem).then(response=>{
          if (response) {
            localStorage.setItem('auth-token',response.token)
            this.$router.push({
              path:'/'
            })
          }
        });
    }
  }
}
</script>

<style lang="css">
</style>
